#include <iostream>
#include <sys/types.h>
#include <unistd.h>

int main()
{
    pid_t id = fork();   //子进程创建

    if(id == 0)  //子进程
    {
        while(true)
        {
            printf("Child Process, pid:%d, ppid:%d\n", getpid(), getppid());
            sleep(1);
        }
    }
    else if(id > 0)   //父进程 
    {

        while(true)
        {
            printf("Parent Process, pid:%d, ppid:%d\n", getpid(), getppid());
            sleep(1);
        }
    }

    return 0;
}
